import 'result.dart';

class ServerResult<T> {
  bool success;
  String message;
  T? data;

  ServerResult({this.success = true, this.message = "", this.data});

  bool get fail => !success;

  factory ServerResult.fromResult(Result result, {T? data}) {
    return ServerResult(
        success: result.isSuccess, message: result.message, data: data);
  }

  @override
  String toString() {
    // TODO: implement toString
    return "success:" +
        success.toString() +
        " ,message:" +
        message +
        " ,data:" +
        data.toString();
  }
}
